#ifndef __BYTEARRAYS_H__
#define __BYTEARRAYS_H__

#include <vector>
#include <string>

#include "env.h"

class byteArrays
{
public:
	byteArrays();
	byteArrays(int t, void* d, int len);
	byteArrays(const byteArrays& ba);
	~byteArrays();

public:
	int readInt();
	short readShort();
	char readByte();
	std::string readString();
	void* readIBytes();
	byteArrays readByteArrays();

	int writeInt(int d, int pos);int writeInt(int d);
	int writeShort(short d, int pos);int writeShort(short d);
	int writeByte(char d, int pos);int writeByte(char d);
	int writeString(std::string d, int pos);int writeString(std::string d);
	int writeIBytes(void* d, int pos);int writeIBytes(void* d);
	int writeByteArrays(byteArrays ba, int pos);int writeByteArrays(byteArrays ba);

public:
	bool checkByteArrays(int type);
	int getlength();
	void* toVoid();
	void clear();
	int isEOF();
	int reset();
	byteArrays& operator=(const byteArrays& ba);

	int memindex;char* data;int datalen;
	int cursor;
};

class ByteArrayException : public exception
{
public:
	ByteArrayException() throw();
	void reset(int c, int t, int l, int m) throw();
	void printstack() throw();
	void printdata() throw();
private:
	int clientindex, type, len, memindex;
};

extern byteArrays blankba;

extern class ByteArrayException baExecption;

#endif //__BYTEARRAYS_H__
